//
//  CZEmoticonModel.swift
//  微博
//
//  Created by 霸气的刘吉庆 on 16/4/26.
//  Copyright © 2016年 ios. All rights reserved.
//

import UIKit

class CZEmoticonModel: NSObject,NSCoding {
    
    //表情描述的字符串
    var chs: String?
    //emoji表情的code,code可以理解为表情文字
    var code: String?
    //如果为1代表的是emoji表情,直接显示字符串就行了,如果是0代表的是图片的表情
    var type: String?
    //图片表情对应的图片的名字
    var png: String?
    //当前表情属性那个文件夹,方便以后分组取数据
    var folderName: String?
    
    init(dict: [String: AnyObject]) {
        
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    //归档和接档,保存最近的表情图片
    //接档
    required init?(coder decoder: NSCoder) {
        chs = decoder.decodeObjectForKey("chs") as? String
        code = decoder.decodeObjectForKey("code") as? String
        type = decoder.decodeObjectForKey("type") as? String
        png = decoder.decodeObjectForKey("png") as? String
        folderName = decoder.decodeObjectForKey("folderName") as? String
    }
    //归档
    func encodeWithCoder(enCoder: NSCoder) {
        enCoder.encodeObject(chs, forKey: "chs")
        enCoder.encodeObject(code, forKey: "code")
        enCoder.encodeObject(type, forKey: "type")
        enCoder.encodeObject(png, forKey: "png")
        enCoder.encodeObject(folderName, forKey: "folderName")
    }
    //重写一个discription的方法,没有提示
    override var description: String {
     
        let keys = ["chs","code","type"]
        return dictionaryWithValuesForKeys(keys).description
        
    }
    
    
    

}
